class Solution
{
public:
    vector<int> singleNumber(vector<int> &nums)
    {
        int allXor = 0;
        for (int num : nums)
        {
            allXor ^= num;
        }
        int lowBit = 1;
        while (!(allXor & lowBit))
        {
            lowBit = lowBit << 1;
        }
        int a1 = 0;
        int a2 = 0;
        for (int num : nums)
        {
            if (num & lowBit)
            {
                a1 ^= num;
            }
            else
            {
                a2 ^= num;
            }
        }
        return {a1, a2};
    }
};